#!/usr/bin/env python

infname = "barrier_mark_oneloop.dat"
outbase = "oneloop_%s.dat"

samples = dict()

def parse_file(file):
    infile = open(file,"r")
    last = 0
    while infile:
        line = infile.readline()
        s = line.split()
        n = len(s)
        if n == 0:
            break
        if s[0] == '#':
            continue
        n_threads = int(s[0])
        block_size = int(s[1])
        tm = float(s[4])
        tme = float(s[5])
        if last != n_threads:
            last = n_threads
            samples[n_threads] = list()
        samples[n_threads].append([block_size,tm, tme])
        #print s;

parse_file(infname)

#print samples
for nt, s in samples.items():
    fname = outbase%(nt)
    f = open(fname, "w")
    for l in s:
        f.write("%d %f %f\n"%(l[0], l[1], l[2]))

